<template>
  <div class="content">
    <div v-for="p in data" :key="p.caipin_id">
      <h1 class="h1">{{p.caipin}}</h1>
      <div class="datu">
        <img
          :src="`/小组项目图片/食谱分类/${leixing}/${p.caipin}/${p.tupian2}`"
        />
      </div>
      <div class="cailiao">
        <h2 class="cailiaobiaoti">材料</h2>
      </div>
      <div>
        <p class="cailiaoxiangqing">
          {{p.cauliaojuti}}
        </p>
      </div>
      <div class="zuofa">
        <h2 class="zuofabiaoti">做法</h2>
      </div>
      <div class="zuofaxiangqing">
        <p v-html="p.zuofaxiangqing">
        </p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: [], //用于存储请求回来的数据
      leixing:''
    };
  },
  mounted() {
    this.ZuoFa();
  },
  methods: {
    ZuoFa() {
      let url = `http://127.0.0.1:3000/v1/Shipufenlei/jutizuofa/${this.$route.query.type}`;
      this.axios.get(url).then((res) => {
        console.log(res);
        // 请求的数据保存在data中
        this.data = res.data.data;
        // 打印点击的菜品
        console.log(this.$route.query.name);
        this.leixing = this.$route.query.name;
        console.log(this.leixing)
      });
    },
  },
};
</script>

<style scoped>
.content {
  padding-top: 6px;
  padding-bottom: 12px;
}
.h1 {
  height: 47px;
  line-height: 47px;
  text-align: center;
  color: #817c74;
  font-size: 18px;
}
.datu {
  margin-top: 14px;
  margin-left: 10px;
  margin-right: 10px;
}
.datu img {
  width: 100%;
  vertical-align: middle;
  border: 0;
}
.cailiao {
  padding: 0 10px;
}
.cailiaobiaoti {
  padding-top: 11px;
  padding-bottom: 11px;
  color: #817c74;
  font-size: 100%;
  line-height: normal;
  font-weight: 300;
}
.cailiaoxiangqing {
  padding-top: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eae6e3;
  border-top: 1px solid #eae6e3;
  margin-left: 10px;
  margin-right: 10px;
}
.zuofa {
  padding: 0 10px;
}
.zuofabiaoti {
  padding-top: 11px;
  padding-bottom: 11px;
  color: #817c74;
  font-size: 100%;
  line-height: normal;
  font-weight: 300;
}
.zuofaxiangqing {
  padding-bottom: 12px;
  margin-left: 10px;
  margin-right: 10px;
}
</style>